#ifndef __CLIENT_SERVER_H__
#define __CLIENT_SERVER_H__
#include <string>
#include <json/json.h>
#include <boost/function.hpp>
#include "WebSocket.h"
#include "redis_subscriber.h"


class CClientServer
{
public:
    CClientServer();
    ~CClientServer();
public:
    static CClientServer* instance();
public:
    void run();
private:
    void SendWSData(const std::string &openId, const std::string &message);
    static void RecieveMessage(const char *channel_name, const char *message, int len);
private:
    typedef boost::function<void(CClientServer*, const std::string&, Json::Value &)> Method;
    typedef std::map<std::string, Method> MethodMap;
    static	CClientServer* _instance;	
    MethodMap m_methodMap;

    CRedisSubscriber m_subscriber;
    CRedisSubscriber::NotifyMessageFn m_notifyMessageFn;

    CWebSocket m_websocket;
};


#endif

